﻿using UnityEngine;
using System.Collections;
using Slate;

namespace XSlate {

    public class XGroup : CutsceneGroup
    {
        [SerializeField]
        private string name_;
        [SerializeField]
        private GameObject actor_;

        [SerializeField]
        private ActorReferenceMode refMode_;


        [SerializeField]
        [UnityEngine.Serialization.FormerlySerializedAs("_initialTransformation")]
        private ActorInitialTransformation initialCoordinates_;

        [SerializeField]
        [ShowIf("initialCoordinates_", 1)]
        private Vector3 initialLocalPosition_;
        [SerializeField]
        [ShowIf("initialCoordinates_",1)]
        private Vector3 initialLocalRotation_;
        [SerializeField]
        [ShowIf("initialCoordinates_", 1)]
        private bool displayVirtualMeshGizmo_ = true;

        public override string name {
            get{
                return string.IsNullOrEmpty(this.name_) ? this.actor_ == null ? "Null" : this.actor_.name : this.name_;
            }
            set {
                this.name_ = value;
            }
        }
        public override GameObject actor {
            get {
                return base.ResolveActor(this.actor_);
            }
            set {
                if (actor_ != value) {
                    actor_ = value;
#if UNITY_EDITOR
                    if (value != null && !Application.isPlaying) {
                        if (UnityEditor.EditorUtility.IsPersistent(value)) {
                            refMode_ = ActorReferenceMode.UseInstanceHideOriginal;
                            this.initialTransformation = ActorInitialTransformation.UseLocal;
                        }
                    }
#endif
                }

            }
        }
        public override ActorReferenceMode referenceMode {
            get {
                return this.refMode_;
            }
            set {
                this.refMode_ = value;
            }
        }
        public override ActorInitialTransformation initialTransformation {
            get {
                return this.initialTransformation;
            }
            set {
                this.initialTransformation = value;
            }
        }
        public override Vector3 initialLocalPosition {
            get {
                return this.initialLocalPosition_;
            }
            set {
                this.initialLocalPosition_ = value;
            }
        }
        public override Vector3 initialLocalRotation {
            get {
                return this.initialLocalRotation_;
            }
            set {
                this.initialLocalRotation_ = value;
            }
        }
        public override bool displayVirtualMeshGizmo {
            get {
                return this.displayVirtualMeshGizmo_;
            }
            set {
                this.displayVirtualMeshGizmo_ = value;
            }
        }


    }
}



